package com.fxsh168.server.activity;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.Nullable;
import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.ImageView;

import com.fxsh168.server.R;


public class Activity_start extends Activity {
    AlphaAnimation mAlphaAnimation;
    ImageView ima_start;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_start);
        ima_start = (ImageView) findViewById(R.id.ima_start);
//        动画设置
        mAlphaAnimation = new AlphaAnimation(0.0f, 1.0f);
        mAlphaAnimation.setDuration(2000);
        mAlphaAnimation.setFillAfter(true);
        mAlphaAnimation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                handler.sendEmptyMessageDelayed(0, 1000);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });
        ima_start.setAnimation(Activity_start.this.mAlphaAnimation);
        ima_start.startAnimation(Activity_start.this.mAlphaAnimation);
    }

    Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            Activity_start.this.GoOtherActivity();
            finish();
        }
    };

    void GoOtherActivity() {
        startActivity(new Intent(this, MainActivity.class));
        finish();
    }

    @Override
    protected void onDestroy() {
        handler.removeMessages(0);
        super.onDestroy();

    }
}
